feat(http)!: add cross-site request forgery protection #1411
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for cross-site request forgery protection. This is a pretty important feature to have, so it will be enabled by default. Technically, this is thus a breaking change.
Non-read requests now require a CSRF token to be present. It can be a
_tokenin the request body or in ax-xsrf-tokenheader. All requests will return the CSRF token in axsrf-tokencookie. This pattern is standard across AJAX clients, which means there is no particular setup needed for them.For standard HTML forms, a
<x-csrf-token />component is available. It renders a hidden_tokeninput. Otherwise, the token is available as thetokenproperty ofTempest\Http\Session.Note that after #1346, we might iterate on this so the cookie can be encrypted, instead of a plaintext UUID.